<?php 
class AdModel extends Object
{
	public $BrandId;
	public $BrandTitle;
	public $Title;
	public $Year;
	public $YearEnd;
	public $Active;
	
	public function AdModel($values = '')
	{ 
		self::setDataTable('am_models');
		if(is_array($values))
		{ self::setValues($values); }
	}
	
	public function __toString()
	{
		$out  = '';
		$out .= self::getId();
		$out .= self::getTitle();
		return $out;
	}
	
	public function getBrandId() { return intval($this->BrandId); }
	public function getYear() { return intval($this->Year); }
	public function getYearEnd() { return intval($this->YearEnd); }
	
	public function setBrandId($val) { $this->BrandId=intval($val); }
	public function setYear($val) { $this->Year=intval($val); }
	public function setYearEnd($val) { $this->YearEnd=intval($val); }
	
	function update()
	{
		if((self::getId() > 0) && (self::getDataChanged()))
		{
			$sql  = 'UPDATE '.DB_PERFIX.self::getDataTable().' SET ';
			$sql .= '`BrandId`='.self::getBrandId().', ';
			$sql .= '`Title`="'.self::formatText(self::getTitle()).'", ';
			$sql .= '`Year`='.self::getYear().', ';
			$sql .= '`YearEnd`='.self::getYearEnd().', ';
			$sql .= '`active`='.self::getActive().' ';
			$sql .= ' WHERE Id='.self::getId().' LIMIT 1;';
			mysql_query($sql);
		}
	}
}
?>